﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<OverrideThis.ContactManager.WebSite.Models.PersonListViewModel>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Contact Management
 </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
	<h2>Index</h2>
	<p>
		<%: Html.ActionLink("New Person", "Create") %> | 
		<%: Html.ActionLink("Rss", "Rss") %> |
		<%: Html.ActionLink("Json", "Index", new { id = Model.SelectedPersonId, f = "Json" }, null) %> |
		<%: Html.ActionLink("Xml", "Xml") %></p>
	<table class="tablesorter">
		<thead>
			<tr>
				<th></th>
				<th>Id</th>
				<th>LastName</th>
				<th>FirstName</th>
				<th>Country</th>
				<th>BirthDate</th>
			</tr>
		</thead>
	<% foreach (var item in Model.Persons) { %>
		<tbody>
		<tr <%: (item.Id == Model.SelectedPersonId) ? "style='background-color: lightskyblue'" : ""  %>>
			<td>
				<%: Html.ActionLink("Edit", "Edit", new { id=item.Id }) %> |
				<%: Html.ActionLink("Detail", "Detail", new { id=item.Id })%> |
				<%: Html.ActionLink("Delete", "Delete", new { id=item.Id })%> |
				<%: Html.ActionLink("Contacts", "Index", new { id=item.Id })%>
			</td>
			<td><%: item.Id %></td>
			<td><%: item.Lastname %></td>
			<td><%: item.Firstname %></td>
			<td><%: item.CountryDescription %></td>
			<td><%: Html.ActionLink(item.BirthDate.Value.ToShortDateString(), "BirthDate", new { day = item.BirthDate.Value.Day, month = item.BirthDate.Value.Month, year = item.BirthDate.Value.Year }) %></td>
		</tr>
	<% } %>
		</tbody>
	</table>

	<% if(Model.SelectedPersonId != 0)  { %>
	<%= Html.Partial("Contacts", Model.Persons.FirstOrDefault(p => p.Id == Model.SelectedPersonId)) %>
	<% } %>
	
</asp:Content>

